/*package com.ruoyi.system.utils;

import javax.annotation.PostConstruct;
import javax.annotation.Resource;
import org.slf4j.Logger;
import org.slf4j.LoggerFactory;
import org.springframework.amqp.core.Message;
import org.springframework.amqp.rabbit.connection.CorrelationData;
import org.springframework.amqp.rabbit.core.RabbitTemplate;
import org.springframework.stereotype.Component;

@Component
public class AmqpAckConfig implements RabbitTemplate.ConfirmCallback, RabbitTemplate.ReturnCallback {
    private static final Logger log = LoggerFactory.getLogger(AmqpAckConfig.class);

    @Resource
    private RabbitTemplate rabbitTemplate;

    @PostConstruct
    public void init() {
        this.rabbitTemplate.setConfirmCallback(this);
        this.rabbitTemplate.setReturnCallback(this);
    }

    public void returnedMessage(Message message, int replyCode, String replyText, String exchange, String routingKey) {
        log.error("消息{},被交换机{}退回，退回原因：{}，路由key:{}", new Object[] { new String(message
                .getBody()), exchange, replyText, routingKey });
    }

    public void confirm(CorrelationData correlationData, boolean ack, String cause) {
        String id = (correlationData != null) ? correlationData.getId() : "";
        if (ack) {
            log.info("交换机已经收到Id为:{}的消息", id);
        } else {
            log.info("交换机还未收到Id为:{}的消息,由于原因:{} ", id, cause);
        }
    }
}*/

